// 笔试强训day23：打怪

#include <iostream>
using namespace std;

int main() {
    int t = 0; cin >> t;
    int h = 0, a = 0, H = 0, A = 0;
    while(t--)
    {
        cin >> h >> a >> H >> A;
        if(a >= H)
            cout << -1 << endl;
        else
        {
            int ans = 0, losth = 0, itsh = H;
            while(itsh > a)
            {
                itsh -= a;
                losth += A;
            }
            ans = h / losth;
            if(h % losth == 0)
                ans -= 1;

            cout << ans << endl;
        }
    }
}